import { Scene } from '@babylonjs/core/scene';
import { AbstractScrollList, IAbstractScrollListOptions } from '../../../gui/composite/abstract-scroll-list';
import { CreateGuideItem, GuideItem, IGuideItemOptions } from './guide-item';


/**
 * 操作指导滚动容器参数对象接口
 */
interface IScrollGuideItemListOptions extends IAbstractScrollListOptions { }


/**
 * 操作指导滚动容器
 * @param name 名称
 * @param scene 场景
 * @param options 参数对象
 */
class ScrollGuideItemList extends AbstractScrollList<GuideItem, IGuideItemOptions> {

    constructor(name: string, scene: Scene, options?: IScrollGuideItemListOptions) {
        const ops = options || {};
        ops.alwaysInoperable = true;
        super(name, scene, ops);
        this.updateBlockSize();
    }

    protected generateMember(name: string, options?: IGuideItemOptions | undefined): GuideItem {
        const ops: IGuideItemOptions = options || {};
        ops.inoperable = true;

        return CreateGuideItem(name, this.scene, ops);
    }

}


/**
 * 创建操作指导滚动容器
 * @param name 名称
 * @param scene 场景
 * @param options 参数对象
 * @param items 成员参数对象
 * @returns 操作指导滚动容器
 */
const CreateScrollGuideItemList = (name: string, scene: Scene, options: IScrollGuideItemListOptions, items: Array<{ name: string, option?: IGuideItemOptions }>): ScrollGuideItemList => {
    const sg = new ScrollGuideItemList(name, scene, options);
    for (const item of items) {
        sg.add(item.name, item.option);
    }
    return sg;
};


export { ScrollGuideItemList, CreateScrollGuideItemList };
export type { IScrollGuideItemListOptions };